#ifndef OPENGLIMAGE_H_
#define OPENGLIMAGE_H_

#include "GL/gl.h"
#include "WinPt.h"
#include "TexPt.h"

class OpenGLImage {
public:
	OpenGLImage(char* filename);
	virtual
	~OpenGLImage();
	inline int getWidth() {
		return width;
	}
	inline int getHeight() {
		return height;
	}
	inline GLuint getTexID() {
		return textureID;
	}
	inline GLubyte* getImageData() {
		return file_data;
	}
	void draw();
	void mouseFunc(int button, int state, int x, int y);
	void motionFunc(int x, int y);
	bool convWinPtToTexPt(TexPt startTexPts[4], TexPt endTexPts[4]);
private:
	void convViewToWinPt(WinPt quadPts[4], GLint viewport[4]);
	void convWinPtToView(GLint viewport[4], WinPt quadPts[4]);
	void drawQuad(WinPt quadPts[4], GLfloat red, GLfloat green, GLfloat blue);
	void finalizeQuad(WinPt quad[4], int x, int y);
	void initQuad(WinPt quad[4], int x, int y);
	int width, height, texWidth, texHeight;
	GLubyte* file_data;
	GLuint textureID;
	WinPt start[4];
	WinPt end[4];
	int button;
	WinPt* mobile;
	static const int HIT_BOX = 10;
};

#endif /* OPENGLIMAGE_H_ */
